import request from '@/utils/request'

/**
 * 采购退货分页查询
 * @param {*} data = {pageNo: 0, pageSize: 0, param: {storeId}}
 */
export function pageList(form, pageSize, currentPage) {
  const data = {
    param: form,
    pageSize: pageSize,
    pageNo: currentPage
  }
  return request.post('/sq/brandPurchaseReturn/page  ', data)
}

/**
 * 配件分页查询
 * @param {*} data = {pageNo: 0, pageSize: 0, param: {purchaseReturnId}}
 */
export function partsPage(form, pageSize, currentPage) {
  const data = {
    param: form,
    pageSize: pageSize,
    pageNo: currentPage
  }
  return request.post('/sq/brandPurchaseReturn/partsPage', data)
}

/**
 * 新增采购退货
 * @param {*} data
 */
export function save(data) {
  return request.post('/sq/brandPurchaseReturn/save', data)
}

/**
 * 更新采购退货
 * @param {*} data
 */
export function update(data) {
  return request.put('/sq/brandPurchaseReturn/save', data)
}

/**
 * 删除采购退货
 * @param {*} id
 */
export function deleteById(id) {
  return request.delete(`/sq/brandPurchaseReturn/del/${id}`)
}

/**
 * 编辑采购退货详情
 * @param {*} id
 */
export function editDetailById(id) {
  return request.get(`/sq/brandPurchaseReturn/findById/${id}`)
}

/**
 * 采购退货详情
 * @param {*} id
 */
export function detailById(id) {
  return request.get(`/sq/brandPurchaseReturn/detail/${id}`)
}

/**
 * 获取退货编号
 */
export function getPurchaseCode() {
  return request.get(`/sq/brandPurchaseReturn/getPurchaseCode`)
}

/**
 * 查询来源单号
 * data={returnType, sourceCodeOrStoreId}
 */
export function findSourceCode(returnType, sourceCodeOrStoreId) {
  return request.get(`/sq/brandPurchaseReturn/findSourceCode/${returnType}/${sourceCodeOrStoreId}`)
}

/**
 * 更新退货状态
 * @param {*} data
 */
export function updateStatus(id, status) {
  return request.put(`/sq/brandPurchaseReturn/updateStatus/${id}?status=${status}`)
}
